const fs = require("fs");
const path = require("path");

const pathFrom = path.join(__dirname,"/1.txt");
const pathTo = path.join(__dirname,"/8.txt");

const readStream = fs.createReadStream(pathFrom);
const writeStream = fs.createWriteStream(pathTo);

readStream.pipe(writeStream);

writeStream.on("close",()=> {
    const fileObj = fs.statSync(pathFrom);
    // 赋予文件操作权限
    fs.chmodSync(pathTo,fileObj.mode);
})
